<template>
    <div>
        <h2>注册</h2>
        <table>
            <tr>
                <td>用户名</td>
                <td><input type="text" v-model="state.username"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="state.password"></td>
            </tr>
            <tr>
                <td colspan="2"><button @click="addAdmin">注册</button></td>

            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import axios from 'axios';

let data = reactive({
    state: {
        username: '',
        password: ''
    }
})
let { state } = toRefs(data);
const addAdmin = () => {

    let obj = {
        username: state.value.username,
        password: state.value.password
    }
    axios({
        url: '/api/Admin/login',
        method: 'get',
        params: obj
    })
        .catch(res => {
            console.log(res);
            console.log(res.data.data)
            if (res.data.data != null) {
                alert("注册成功");

            } else {
                alert("注册成功");
            }
        })
        .then(err => {
            console.log(err);
        })
}
</script>

<style scoped>

</style>